#include <bits/stdc++.h>

using namespace std;

int a[15][15],vx[15][15],vy[15][15],vc[5][5][15];
void dfs(int x,int y){
    if(x==9){
        for(int i=0;i<9;i++){
            for(int j=0;j<9;j++){
                cout<<a[i][j]<<' ';
            }
            cout<<endl;
        }
        exit(0);
    }
    if(y==9){
        dfs(x+1,0);
        return;
    }
    if(a[x][y]!=0){
        dfs(x,y+1);
    }
    else{
        for(int i=1;i<=9;i++){
            if(!vx[x][i]&&!vy[y][i]&&!vc[x/3][y/3][i]){
                vx[x][i] = 1;
                vy[y][i] = 1;
                vc[x/3][y/3][i] = 1;
                a[x][y]=i;
                dfs(x,y+1);
                a[x][y]=0;
                vx[x][i] = 0;
                vy[y][i] = 0;
                vc[x/3][y/3][i] = 0;
            }
        }
    }
}
int main()
{
    for(int i=0;i<9;i++){
        for(int j=0;j<9;j++){
            cin>>a[i][j];
            vx[i][a[i][j]] = 1;
            vy[j][a[i][j]] = 1;
            vc[i/3][j/3][a[i][j]] = 1;
        }
    }
    dfs(0,0);
    return 0;
}
